<!-- 登录页 -->
<template>
	<view>
		<view class="title">
		</view>

		<view class="input_title">
			账号
		</view>
		<input class="input_class" v-model="username" type="text" placeholder="请输入账号" placeholder-style="color:#999999;">
		<view class="input_title">
			密码
		</view>
		<view class="input_class" style="display: flex;flex-direction: row;justify-content: space-between;">
			  <input style="width: 400rpx;" v-model="password" placeholder="请输入密码" placeholder-style="color:#999999;">
		</view>
		
		<view class="login_btn_off all_text_center" v-if="!isCanLogin">
			登录
		</view>
		<view class="login_btn all_text_center" v-else @click="login()">
			登录
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				username:'',
				password:'',
			
			}
		},
		computed:{
			isCanLogin(){
				if(this.username !=='' && this.password !== ''){
					return true
				}else{
					return false
				}
			}
		},
		
		onLoad() {
			
		},
		methods: {
			async login(){
				const res = await this.$myRequest({
					url:'ChatPublic/login_by_password',
					method: 'POST',
					data: {
						username: this.username,
						password:this.password,
					},
				});
				if (res.data.code != 200) return uni.showToast({
					title: res.data.datas.msg,
					icon: 'none'
				})
				uni.showToast({
					title: res.data.datas.msg,
					icon: 'none'
				})
				uni.setStorage({
					key: 'chat_member_id',
					data: res.data.datas.info.member_id
				})
				
				uni.setStorage({
					key: 'chat_token',
					data: res.data.datas.info.token
				})
				
				uni.setStorage({
					key: 'chat_nickname',
					data: res.data.datas.info.nickname
				})
				
				uni.setStorage({
					key: 'chat_is_leader',
					data: res.data.datas.info.is_leader
				})
				
				setTimeout(() => {
					uni.reLaunch({
						url:'/packageChat/GroupList/GroupList'
					})
				}, 1500);
			}
			
		}
	}
</script>

<style lang="scss">
	page {
		display: flex;
		justify-content: center;
	}
	.argeement_line {
		display: flex;
		flex-direction: row;
		align-items: center;
		margin-top: 20rpx;
		image{
			width: 26rpx;
			height: 26rpx;
		}
		.left_box {
			width: 22rpx;
			height: 22rpx;
			border-radius: 8rpx;
			border: 1rpx solid #999999;
		}
	
		.rigit {
			font-size: 24rpx;
			margin-left: 20rpx;
	
			color: #9E9E9E;
		}
	}

	.title {
		text-align: center;
		margin-top: 200rpx;
		font-size: 50rpx;
		font-weight: 500;
		color: #333333;
	}

	.input_title {
		margin-top: 100rpx;
		font-size: 32rpx;
		font-weight: 500;
		color: #333333;
	}

	.input_class {
		margin-top: 20rpx;
		width: 540rpx;
		border-bottom: 1rpx solid #D8D8D8;
		padding-bottom: 10rpx;
		padding-left: 5rpx;
	}

	.mini_text {
		font-weight: 500;
		color: #008BFE;
		font-size: 26rpx;
		display: flex;
		justify-content: flex-end;
		margin-top: 20rpx;
	}

	.login_btn {
		width: 540rpx;
		height: 80rpx;
		background: #008BFE;
		color: #ffffff;
		box-shadow: 0px 1px 4px 1px rgba(0, 0, 0, 0.4);
		border-radius: 12rpx;
		font-size: 36rpx;
		margin-top: 60rpx;
	}

	.login_btn_off {
		width: 540rpx;
		height: 80rpx;
		background: #EFEFEF;
		color: #999999;
		box-shadow: 0px 1px 4px 1px rgba(0, 0, 0, 0.4);
		border-radius: 12rpx;
		font-size: 36rpx;
		margin-top: 60rpx;
	}

	.mini_text_line {
		width: 540rpx;
		margin-top: 25rpx;
		font-weight: 500;
		color: #008BFE;
		font-size: 26rpx;
		display: flex;
		justify-content: space-between;
	}
</style>
